package com.sys.platform.controller;


import cn.hutool.core.bean.BeanUtil;
import com.sys.platform.common.web.controller.BaseController;
import com.sys.platform.common.web.page.TableDataInfo;
import com.sys.platform.entity.EntranceGuard;
import com.sys.platform.entity.EntranceGuardAccessRecord;
import com.sys.platform.service.IEntranceGuardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags = "门禁设备管理")
@RestController
@RequestMapping("/entranceGuard")
public class EntranceGuardController extends BaseController {

    @Resource
    private IEntranceGuardService entranceGuardService;

    @ApiOperation("查询门禁列表")
    @GetMapping("list")
    public TableDataInfo list(EntranceGuard dto) {
        startPage();
        EntranceGuard entranceGuard = new EntranceGuard();
        BeanUtil.copyProperties(dto, entranceGuard);
        List<EntranceGuard> entranceGuardList = entranceGuardService.selectEntranceGuardList(entranceGuard);
        return getDataTable(entranceGuardList);
    }

    @ApiOperation("查询门禁访问记录")
    @GetMapping("accessRecordList")
    public TableDataInfo accessRecordList(EntranceGuardAccessRecord dto) {
        startPage();
        EntranceGuardAccessRecord accessRecord = new EntranceGuardAccessRecord();
        BeanUtil.copyProperties(dto, accessRecord);
        List<EntranceGuardAccessRecord> entranceGuardAccessRecordList = entranceGuardService.selectEntranceGuardAccessRecordList(accessRecord);
        return getDataTable(entranceGuardAccessRecordList);
    }

}
